package itBean;
public class Penguin {
    private String name; //宠物的名字
    private String type; //宠物的类型
    private String sex;//企鹅的性别
    private int health; //企鹅的健康值
    private int love;//亲密度

    public Penguin() {
    }

    public Penguin(String name, String type, String sex, int health) {
        this.name = name;
        this.type = type;
        this.sex = sex;
        this.health = health;

    }

    public int getLove() {
        return love;
    }
    public void setLove(int love) {
        if (love<0 || love>100){
            System.out.println("亲密度应该在0-100之间，默认值为10");
        this.love = 10;
        return;
        }
        this.love=love;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String isSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        if (health < 0 && health > 100) {
            System.out.println("健康值应该在0-100之间，默认值为60");
            this.health = 60;
            return;
        }
        this.health=health;
    }

    public void print() {
        System.out.println("宠物的自白：\n我的名字叫" + this.getName() + "，健康值是" + this.health + ",和主人的亲密度是" + this.love);
    }
}
